package com.TreeMap;

import java.util.TreeMap;
import java.util.function.BiConsumer;

public class TreeMapTest2 {
    public static void main(String[] args) {
        TreeMap<Student,String> m = new TreeMap<>();

        //添加学生对象：
        Student s1 = new Student("小王", 18);
        Student s2 = new Student("小张", 18);
        Student s3 = new Student("小黄", 28);



        //添加元素：
        m.put(s1,"beijing");
        m.put(s2,"shanghai");
        m.put(s3,"wuhan");

        //遍历：
        m.forEach((student, s)->
                System.out.println(student.getName() + " " +student.getAge()
                + " " + s)
        );

    }
}
